using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

    /// <summary>
    /// AI 服务商
    /// </summary>
    public class AiProvider
    {
        /// <summary>
        /// AI 服务提供商名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// AI 服务提供商编码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// ApiKey
        /// </summary>
        /// <value></value>
        public string ApiKey { get; set; }

        /// <summary>
        /// APiEndpoint
        /// </summary>
        /// <value></value>
        public string ApiEndpoint { get; set; }


        public EnumAiProviderType AiType { get; set; }

        public List<ApiService> ApiServices { get; set; }

        public ApiService? GetEmbeddingApiService() => GetApiService("embeddings");

        public ApiService? GetChatCompletionApiService() => GetApiService("chat-completions");

        private ApiService? GetApiService(string apiServiceName) => ApiServices.FirstOrDefault(x => x.Name == apiServiceName);
    }

    /// <summary>
    /// AI提供商分类
    /// </summary> 
    public enum EnumAiProviderType
    {
        OpenAI,
        AzureOpenAI,
        OpenAI_Compatible,
        Onnx,
        Other
    }

    /// <summary>
    /// AI 服务提供商提供的API 服务
    /// </summary>
    /// <param name="Name">Api名称</param>
    /// <param name="ModelId">模型编码</param>
    ///  <param name="Models">可用模型列表</param>
    public record ApiService(string Name, string ModelId, string[]? ModelIds = null);
